/*
 * Created on 12/Abr/2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.cyborgas.xmltool.tabsheets;

import java.io.File;
import java.net.URI;

import org.cyborgas.xmltool.MainWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;


/**
 * @author rino
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class XmlViewTab {

	private MainWindow mainWindow;

	// controls
	private Browser xmlWebBrowser;
	
	
	
	public XmlViewTab(MainWindow window) {
		this.mainWindow = window;
	}
	
	public Composite createControls(Composite parent) {

		// containers start
		Composite mainPane = new Composite(parent, SWT.NULL);
		mainPane.setLayout(new FillLayout());
		

		// containers end
		// controls start
		xmlWebBrowser = new Browser(mainPane, SWT.BORDER);
		xmlWebBrowser.setUrl("about:blank");
		
		// controls end

		return mainPane;
	}


	public void setText(File file) {
		//System.out.println(file.toURL().toExternalForm());
		//xmlWebBrowser.setUrl("file:///D:/nph-im_sia.xml");
		xmlWebBrowser.setUrl(file.getAbsolutePath());
	}	

	public void setText(URI url) {
		xmlWebBrowser.setUrl(url.toString());
	}

	public void dispose() {
		if (xmlWebBrowser != null) {
			xmlWebBrowser.dispose();
		} 
		xmlWebBrowser = null;
	}

}
